<%-- 
    Document   : Tabla
    Created on : 05-11-2013, 02:46:00 PM
    Author     : Urena
--%>

<%@page import="Model.Customer"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>


    <center> <h2>TABLA</h2>
        <br>
        <a href="index.jsp"> VOLVER AL FORMULARIO<a/>
            <br>
            <br>
            Buscar: 
            <form method="post" action="FormularioServlet">
                <select name="busqueda">
                    <option value="name" >Nombre</option>
                    <option value="lastname" >Apellido</option>
                    <option value="address" >Direccion</option>
                    <option value="phone" >Telefono</option>
                    <option value="email" >Sexo</option>
                    <option value="email" >Email</option>
                </select>
                <input name="texto" type="text" maxlenght="20"> 
                <input name ="buscar"type="submit" value="Go" >
            </form>


            <br>
            <br>

            <form method="post" action="FormularioServlet">
                <table border="2">

                    <tr bgcolor="GRAY" >


                        <th>NOMBRE</th>
                        <th>APELLIDO</th>
                        <th>DIRECCION</th>
                        <th>TELEFONO</th>
                        <th>SEXO</th>
                        <th>E-MAIL</th>
                        <th colspan="3">ACCIONES

                    </tr>


                    <%

                        String tabla = "";

                        List<Customer> list = (List<Customer>) request.getAttribute("lista");


                        for (Customer cust : list) {

                            tabla = tabla
                                    + "<tr>"
                                    + "<td>" + cust.getName() + "</td>"
                                    + "<td>" + cust.getLastname() + "</td>"
                                    + "<td>" + cust.getAddress() + "</td>"
                                    + "<td>" + cust.getPhone() + "</td>"
                                    + "<td>" + cust.getSex() + "</td>"
                                    + "<td>" + cust.getEmail() + "</td>"
                                    + "<td>"
                                    + "<form action=\"FormularioServlet\" method=\"post\">"
                                    + "<input type=\"hidden\" name=\"id\" value=\"" + cust.getId() + "\">"
                                    + "<input name =\"todo\"type=\"submit\" value=\"Editar\" >"
                                    + "<input name =\"todo\"type=\"submit\" value=\"Remover\" >"
                                    + "</form>"
                                    + "</td>"
                                    + "</tr>";
                        }

                        tabla = tabla + "</tabla>" + "</center>" + "</form>";


                    %>
                    <%=tabla%>

                </table>


                <br>
                </body>
                </html>
